package io.github.junxworks.qt.modules.mm.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import io.github.junxworks.ep.core.orm.TBaseMapper;
import io.github.junxworks.qt.modules.mm.dto.FieldDto;
import io.github.junxworks.qt.modules.mm.entity.MmField;
import io.github.junxworks.qt.modules.mm.vo.FieldVo;

@Mapper
public interface FieldMapper extends TBaseMapper<MmField> {

	/**
	 * 查询字段列表
	 *
	 * @param dto the dto
	 * @return the list
	 */
	public List<FieldVo> queryFieldList(FieldDto dto);

	public List<FieldVo> queryFieldDetailByIds(Long[] ids);

	@Select("select * from mm_field where id=#{id}")
	public FieldVo getOneByKey(@Param("id") Long id);

	@Update("update mm_field set status=-1 where id=#{id}")
	public int deleteField(@Param("id") Long id);

	@Select("select ds.datastream_name from mm_ds_field_rela fr,mm_datastream ds where fr.field_id=#{id} and fr.ds_id = ds.id and ds.status=0")
	public List<String> queryDsNameByFieldId(@Param("id") Long fieldId);

	@Select("select f.*,u.name `creatorName` from mm_field f left join ep_s_user u on f.creatorId=u.id  where f.innerCName=#{innerCName} and f.status=0")
	public FieldVo queryFieldDetailByCName(@Param("innerCName") String innerCName);
}
